home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / src.zoo / src / shape.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-17  |  3.4 KB  |  138 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: shape.c,v 1.1 89/03/17 08:21:21 sau Exp $
  9.     $Source: /m1/mgr.new/src/RCS/shape.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /m1/mgr.new/src/RCS/shape.c,v $$Revision: 1.1 $";
  12.  
  13. /* re-shape a window */
  14.  
  15. #include "bitmap.h"
  16. #include <stdio.h>     /* temporary */
  17. #include "defs.h"
  18. #include "font.h"
  19. #include "event.h"
  20.  
  21. #define FSIZE(c)    ((int) (ACTIVE(font)->head.c))
  22.  
  23. /* reshape a window with the mouse */
  24.  
  25. int shape_window()
  26.    {
  27.    int dx=16 ,dy=16 ;
  28.  
  29.    SETMOUSEICON(&mouse_box);
  30.    move_mouse(screen,mouse,&mousex,&mousey,0);
  31.    SETMOUSEICON(&mouse_arrow);
  32.    get_rect(screen,mouse,mousex,mousey,&dx,&dy,0);
  33.    do_button(0);
  34.  
  35.    /* look for shape event here */
  36.  
  37.    do_event(EVENT_SHAPE,active,E_MAIN);
  38.  
  39.    return(shape(mousex,mousey,dx,dy));
  40.    }
  41.  
  42. /* reshape a window to specified dimentions */
  43.  
  44. int
  45. shape(x,y,dx,dy)
  46. int x,y,dx,dy;
  47.    {
  48.    int sx,sy,w,h;
  49.    register WINDOW *win;
  50.    register int i;
  51.  
  52.    if (dx>0) {
  53.       sx= x; w = dx;
  54.       }
  55.    else {
  56.       sx= x+dx; w = -dx;
  57.       }
  58.    if (dy>0) {
  59.       sy= y; h = dy;
  60.       }
  61.    else {
  62.       sy= y+dy; h = -dy;
  63.       }
  64.  
  65.    if (sx < 0) sx = 0;
  66.    
  67.    if (sx + w >= BIT_WIDE(screen))
  68.       w = BIT_WIDE(screen) - sx;
  69.  
  70.    if (sy + h >= BIT_HIGH(screen))
  71.       h = BIT_HIGH(screen) - sy;
  72.  
  73.    if (w < SUM_BDR + ACTIVE(font)->head.wide*MIN_X +1 ||
  74.        h < SUM_BDR + ACTIVE(font)->head.high*MIN_Y +1)
  75.        return(-1);
  76.  
  77. #ifdef ALIGN
  78.    alignwin(screen,&sx,&w,SUM_BDR);
  79. #endif
  80.  
  81.    /* remove current window position */
  82.  
  83.    save_win(active);
  84.    erase_win(ACTIVE(border));
  85.    clip_bad(active);    /* invalidate clip lists */
  86.  
  87.    /* redraw remaining windows */
  88.  
  89.    repair(active);
  90.  
  91.    /* adjust window state */
  92.  
  93.    ACTIVE(x0) = sx;
  94.    ACTIVE(y0) = sy;
  95.    bit_destroy(ACTIVE(window));
  96.    bit_destroy(ACTIVE(border));
  97.    ACTIVE(border) = bit_create(screen,sx,sy,w,h);
  98.    ACTIVE(window) = bit_create(ACTIVE(border),
  99.                     SUM_BDR,SUM_BDR,w-SUM_BDR*2,h-SUM_BDR*2);
  100.  
  101.    for(win=ACTIVE(next);win != (WINDOW *) 0;win=W(next)) {
  102.       if (W(flags)&W_ACTIVE && intersect(active,win))
  103.          save_win(win);
  104.       }
  105.  
  106.    CLEAR(ACTIVE(window),ACTIVE(background));
  107.  
  108.    border(active,BLK_BDR,WH_BDR);
  109.    bit_blit(ACTIVE(border),0,0,BIT_WIDE(ACTIVE(save))-SUM_BDR,
  110.           BIT_HIGH(ACTIVE(save))-SUM_BDR,BIT_SRC,ACTIVE(save),0,0);
  111.  
  112.    /* make sure character cursor is in a good spot */
  113.  
  114.    if (ACTIVE(x) > BIT_WIDE(ACTIVE(window))) {
  115.       ACTIVE(x) = 0;
  116.       ACTIVE(y) += FSIZE(high);
  117.       }
  118.    if (ACTIVE(y) > BIT_HIGH(ACTIVE(window))) {
  119. #ifdef WIERD
  120.       ACTIVE(y) = BIT_HIGH(ACTIVE(window));
  121.       scroll(ACTIVE(window),0,BIT_HIGH(ACTIVE(window)),
  122.              FSIZE(high),ACTIVE(background));
  123.       bit_blit(ACTIVE(window),0,BIT_HIGH(ACTIVE(window))-FSIZE(high),
  124.                BIT_WIDE(ACTIVE(save)),FSIZE(high),BIT_SRC,
  125.                ACTIVE(save),SUM_BDR,BIT_HIGH(ACTIVE(save))-FSIZE(high)-SUM_BDR);
  126. #else
  127.       ACTIVE(y) = BIT_HIGH(ACTIVE(window))-FSIZE(high);
  128. #endif
  129.       }
  130.  
  131.    bit_destroy(ACTIVE(save));
  132.    ACTIVE(save) = (BITMAP *) 0;
  133.  
  134.     clip_bad(active);                    /* invalidate clip lists */
  135.    un_covered();
  136.    return(0);
  137.    }
  138.